package com.ruoyi.project.anquan.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.anquan.domain.SecurityFlfgk;
import com.ruoyi.project.anquan.service.ISecurityFlfgkService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 法律法规Controller
 * 
 * @author ruoyi
 * @date 2020-05-09
 */
@RestController
@RequestMapping("/anquan/flfgk")
public class SecurityFlfgkController extends BaseController
{
    @Autowired
    private ISecurityFlfgkService securityFlfgkService;

    /**
     * 查询法律法规列表
     */
    @PreAuthorize("@ss.hasPermi('anquan:flfgk:list')")
    @GetMapping("/list")
    public TableDataInfo list(SecurityFlfgk securityFlfgk)
    {
        startPage();
        List<SecurityFlfgk> list = securityFlfgkService.selectSecurityFlfgkList(securityFlfgk);
        return getDataTable(list);
    }

    /**
     * 导出法律法规列表
     */
    @PreAuthorize("@ss.hasPermi('anquan:flfgk:export')")
    @Log(title = "法律法规", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SecurityFlfgk securityFlfgk)
    {
        List<SecurityFlfgk> list = securityFlfgkService.selectSecurityFlfgkList(securityFlfgk);
        ExcelUtil<SecurityFlfgk> util = new ExcelUtil<SecurityFlfgk>(SecurityFlfgk.class);
        return util.exportExcel(list, "flfgk");
    }

    /**
     * 获取法律法规详细信息
     */
    @PreAuthorize("@ss.hasPermi('anquan:flfgk:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(securityFlfgkService.selectSecurityFlfgkById(id));
    }

    /**
     * 新增法律法规
     */
    @PreAuthorize("@ss.hasPermi('anquan:flfgk:add')")
    @Log(title = "法律法规", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SecurityFlfgk securityFlfgk)
    {
        return toAjax(securityFlfgkService.insertSecurityFlfgk(securityFlfgk));
    }

    /**
     * 修改法律法规
     */
    @PreAuthorize("@ss.hasPermi('anquan:flfgk:edit')")
    @Log(title = "法律法规", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SecurityFlfgk securityFlfgk)
    {
        return toAjax(securityFlfgkService.updateSecurityFlfgk(securityFlfgk));
    }

    /**
     * 删除法律法规
     */
    @PreAuthorize("@ss.hasPermi('anquan:flfgk:remove')")
    @Log(title = "法律法规", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(securityFlfgkService.deleteSecurityFlfgkByIds(ids));
    }
}
